/*
 * @Author: your name
 * @Date: 2021-11-30 11:03:29
 * @LastEditTime: 2021-12-16 14:43:06
 * @LastEditors: Please set LastEditors
 * @Description: 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 * @FilePath: \express-app\mongoose\test.js
 */

const mongoose = require('./db.js');
let userSchema = mongoose.Schema(
  {
    name: {
      type: String,
      required: true,
      index: true,
    },
    age: {
      type: Number,
      required: true,
    },
    role: {
      type: mongoose.Schema.Types.Mixed, //mongoose.Schema.Types.ObjectId
      required: true,
      default: 1,
    },
    status: {
      type: Number,
      default: 1,
    },
    img_url: {
      type: String,
      default: '',
    },
  },
  {
    versionKey: false, // 设置不需要version  _V:0
  }
);
module.exports = mongoose.model('Users', userSchema, 'users');
